Welcome to the forum.
Where are the if statements??
This section
Code:
-1<a<10 or a==50;
-2<b<11 or b==51;
c=a+b;
should be like
Code:
if( ( -1 < a && a < 10 ) || a == 50)
{
do_something;
}
You need to do the same with the second if statement.
The "||" operator is the OR and the "&&" operator, the AND.
You see, you want your condition to be true if, a is larger than -1 (-1 < a) AND less than 10 (a < 10) OR a to be equal with 50 (a == 50).
You need to do this in order to take random numbers
Code:
srand( (unsigned int)time ( NULL ) );
You should check your indent style as well!
However, you are trying to apply your logic (the if statements), before giving variables a value!! As a result, you need to move your logic, in order o be executed after you give your variables values!
You have a loop that will be executed as long as 1 == 1, which means forever. Not good. That is an infinite loop and will cause your program to run forever!
Let's see another example:
Assume that I want to have a loop, that will be executed again and again, as long as, the variable named "a" has a value less than 5 or equal to 6. Initial variable of "a" is zero. Every time the loop is executed, add 2 to variable "a". Print the final value of "a".
Here is an example solution with comments.
Code:
#include <stdio.h>
#include <stdlib.h>
/* void states that we receive no arguments from cmd */
int main(void)
{
/* Initial value for a. */
int a = 0;
/* We know that our loop is going to be executed at least once,
so a do-while loop is ok.
*/
do{
/* Every time the loop gets executed, add 2 to a. */
a = a + 2;
/* Conitnue looping, while a is less than 5 OR a is equal to 6*/
}while(a < 5 || a == 6);
/* Print value of a.*/
printf("a = %d\n", a);
/* Exit the program. */
return 0;
}
I suggest you run this code in a paper with a pen and see what the value of a will be. Then run the code to test.